home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / (A)TA / (A)TAL.ADF / Basic_Progs / Civil_War (.txt) < prev    next >
AmigaBASIC Source Code  |  1986-11-06  |  13KB  |  455 lines

  1. PRINT  TAB(26) "CIVIL WAR" :PRINT 
  2.  
  3. PRINT  TAB(15) "COURTESY OF CREATIVE COMPUTING MORRISTOWN, NEW JERSEY "
  4. PRINT :PRINT :PRINT 
  5. 'ORIGINAL GAME DESIGN...CRAN, GOODIE, HIBBARD LEXINGTON H. S.
  6. 'MODIFICATIONS...G. PAUL, R. HESS (TIES),1973
  7.  
  8. 'ADAPTED TO `AMY' BY BILL ELLIOTT (BAUG),1988
  9.  
  10. 'COLOUR SCHEME FROM ARTICLE BY JOHN BOS (BAUG NEWSLETTER 4)
  11.  
  12. GOSUB SETSCREEN
  13.  
  14.     DIM s(4),c$(14),m1(14),m2(14),c1(14),c2(14),m(14)
  15.     
  16. 'UNION INFO ON LIKELY CONFEDERATE STATEGY
  17.  
  18.     s(1)=25:s(2)=25:s(3)=25:s(4)=25
  19.     
  20. 'READ HISTORICAL DATA.
  21.     FOR d = 1 TO 14
  22.     READ c$(d),m1(d),m2(d),c1(d),c2(d),m(d)
  23.     NEXT d
  24.     
  25.     LET d = RND(-1)
  26.     PRINT 
  27.     PRINT  "Do you want instructions";
  28. 110 INPUT x$
  29.     IF x$ = "yes" THEN 160
  30.     IF x$ = "no" THEN 370
  31.     PRINT  "yes or no";
  32.     GOTO 110
  33. 160 PRINT 
  34.     PRINT "   This is a Civil War simulation."
  35.     PRINT "To play, type a response when the computer asks."
  36.     PRINT "Remember that all factors are interrelated and that your"
  37.     PRINT "responses could change history. Facts and figures used are"
  38.     PRINT "based on the actual occurence. Most battles tend to result"
  39.     PRINT "as they did in the civil war, but it all depends on you!!"
  40.     
  41.     PRINT "   The object of the game is to win as many battles as ";
  42.     PRINT "possible."
  43.     
  44.     PRINT "   Your choices for defensive strategy are:"
  45.     PRINT 
  46.     PRINT "           (1) Artillery attack"
  47.     PRINT "           (2) Fortification against frontal attack"
  48.     PRINT "           (3) Fortification against flanking maneuvres"
  49.     PRINT "           (4) Falling back "
  50.     PRINT 
  51.     PRINT "   Your choices for offensive strategy are:"
  52.     PRINT 
  53.     PRINT "            (1) Artillery attack"
  54.     PRINT "            (2) Frontal attack"
  55.     PRINT "            (3) Flanking maneuvres"
  56.     PRINT "            (4) Encirclement"
  57.     PRINT "  You may surrender by typing a  `5' for your strategy"
  58.     
  59.      
  60. 370 PRINT 
  61. 380 INPUT " Are there two generals present. (Answer yes or no) ";b$
  62.               IF b$ = "yes" THEN 430
  63.               IF b$ <> "no" THEN 380
  64.     PRINT:PRINT :PRINT "   You are the Confederacy.   Good Luck!"
  65. 430 LET d = 1
  66.     IF b$ <> "yes" THEN 460
  67.     LET d = 2
  68. 460 PRINT "   Select a battle by typing a number from 1 to 14 on"
  69.     PRINT "request. Type any other number to end the simulation."
  70.     PRINT "   A `0' brings back the exact previous battle situation"
  71.     PRINT "allowing you to replay it."
  72.     PRINT     
  73.     PRINT "Note: A negative Food$ entry causes the program to
  74.     PRINT " use entries from the previous battle."
  75.     PRINT 
  76.     PRINT "After requesting a battle, do you wish ";
  77.     PRINT "battle descriptions"
  78. 560 INPUT " Answer yes or no.";x$
  79.     
  80.     IF x$ = "yes" THEN 600
  81.     IF x$ <> "no" THEN 560
  82.     
  83. 600 l=0:w=0:r1=0:q1=0:N3=0:N4=0:p1=0:p2=0:t1=0:t2=0:f(2)=0:h(2)=0
  84.     b(2)=0:r2=0:q2=0:c6=0:f=0:wo=0:y=0:y2=0:u=0:u2=0
  85.     PRINT 
  86.     PRINT 
  87. 620 PRINT 
  88.     PRINT 
  89. 630 INPUT" Which battle do you wish to simulate";a
  90.          IF a <> 0 THEN 660
  91.          IF r <> 0 THEN 1140
  92.      660 IF a <= 0 THEN 2860
  93.          IF a >= 15 THEN 2860
  94.        LET c$ = c$(a)
  95.        LET m1 = m1(a)
  96.        LET m2 = m2(a)
  97.        LET c1 = c1(a)
  98.        LET c2 = c2(a)
  99.        LET m = m(a)
  100.        LET u = 0
  101.  'Inflation calc
  102.         LET i1 = 10 + (l-w)*2
  103.         LET i2 = l0 + (w-l)*2
  104.   'money available
  105.         LET d(1)=100*INT((m1*(100-i1)/2000)*(1+(r1-q1)/(r1+1))+0.5)
  106.         LET d(2) = 100*INT(m2*(100-i2)/2000+0.5)
  107.         IF b$<> "yes" THEN 1050
  108.         LET d(2)=100*INT((m2*(100-i2)/2000)*(1+(r2-q2)/(r2+1))+0.5)
  109. 1050 'men available
  110.         LET m5=INT (m1*(1+(p1-t1)/(m3+1)))
  111.         LET m6=INT (m2*(1+(p2-t2)/(m4+1)))
  112.         LET f1 = 5*m1/6
  113. PRINT 
  114. PRINT 
  115. PRINT 
  116. PRINT
  117. 1100 PRINT "  This is the battle of ";c$
  118.         IF x$ = "no" THEN 1150
  119.         IF a> 11 THEN 1130
  120.      ON a GOTO 3580,3620,3650,3690,3720,3750,3780,3800,3830,3860,3890
  121. 1130 ON a GOTO 3920,3950,3980
  122. 1140 PRINT  c$" Instant replay"
  123. 1150 PRINT 
  124.           PRINT  " ","Confederacy"," Union"
  125.           PRINT "Men",m5,m6
  126.           PRINT "Money","$";d(1),"$";d(2)
  127.           PRINT "Inflation","  ";i1+15;"%"," ";12;"%"
  128.           PRINT 
  129. 'only in printout is Confed inflation = i1 + 15%
  130. 'if two generals, input Confed first
  131.        FOR i = 1 TO d
  132.        IF b$ <> "yes"THEN 1260
  133.        IF i = 2 THEN 1260
  134.        PRINT " Confederate General---";
  135. 1260 INPUT " How much do you wish to spend for food.......";f
  136.         IF f >=0 THEN 1360
  137.         IF r1 <> 0 THEN 1330
  138.         PRINT " No previous entries
  139.         GOTO 1260
  140.         PRINT " Assume you want to keep the same allocations
  141.         PRINT 
  142.         GOTO 1510
  143. 1360 LET f(i) = f
  144.         PRINT" -Salaries..";
  145.         INPUT h(i)
  146.         LET n = 1
  147.         IF h(i) <0 THEN 1490
  148. 1410 PRINT " -Ammunition";
  149.         INPUT b(i)
  150.         LET n = 2
  151.         IF b(i) <0 THEN 1490
  152.         PRINT 
  153.         IF f(i)+h(i)+b(i)<= d(i) THEN 1510
  154.         PRINT " Think again! You have only $";d(i)
  155.         GOTO 1260
  156. 1490 PRINT " Negative values not allowed"
  157.         ON n GOTO 1360,1410
  158. 1510 IF b$ <> "yes" THEN 1550
  159.         IF i = 2 THEN 1550
  160.         PRINT " Union General---";
  161.         NEXT i
  162. 1550 FOR z = 1 TO d
  163.         IF b$ <> "yes" THEN 1620
  164.         ON z GOTO 1580,1600
  165. 1580 PRINT "Confederate ";
  166.         GOTO 1620
  167. 1600 PRINT "      Union ";
  168.  'find morale
  169. 1620 LET o = ((2*f(z)^2+h(z)^2)/f1^2)
  170.          IF o<10 THEN 1660
  171.          PRINT " Morale is high!!!"
  172.          GOTO 1700
  173. 1660 IF o<5 THEN 1690
  174.          PRINT " Morale is fair."
  175.          GOTO 1700
  176. 1690 PRINT " Morale is poor!!"
  177. 1700 IF b$<>"yes" THEN 1760
  178.         LET o(z) = 0
  179.         NEXT z
  180.         LET o2 = o(2)
  181.         LET o = o(1)
  182.         PRINT " Confederate General---";
  183. 1760 '-Actual off/def Battle Situation
  184.         IF n <> 3 THEN 1800
  185.         PRINT "You are on the offensive"
  186.         GOTO 1840
  187. 1800 IF n <> 1 THEN 1830
  188.          PRINT " You are on the defensive..."
  189.          GOTO 1840
  190. 1830 PRINT " Both sides are on the offensive..."
  191. 1840 PRINT 
  192.  
  193. ' choose strategies
  194.           IF b$<> "yes" THEN 1910
  195.           FOR i = 1 TO 2
  196.           ON i GOTO 1890, 1920
  197. 1890 PRINT " Confederate stategy ";
  198. 1910 GOTO 1920
  199. 1920 INPUT " Your stategy ";y        
  200.            IF ABS (y-3) < 3 THEN 1960
  201.            PRINT " Strategy ";y;"not allowed."
  202.            GOTO 1910
  203. 1960 IF b$ = "yes" THEN 2000
  204.            IF y = 5 THEN 2830
  205.            GOSUB 3110
  206.            GOTO 2170
  207. 2000 IF i = 2 THEN 2040
  208.            LET y1 = y
  209.  2020 PRINT " Union stategy ";
  210.            NEXT i
  211. 2040 LET y2 = y
  212.            LET y = y1
  213.            IF y2 = 5 THEN 2020
  214.        'Simulated losses-north
  215.            LET c6 = (2*c2/5)*(1+1/(2*(ABS(y2-y)+1)))
  216.            LET c6 = c6*(1.28+(5*m2/6)/(b(2)+1))
  217.            LET c6 = INT (c6*(1+1/o2)+0.5)
  218.            
  219.        'if loss > men present, rescale losses
  220.            LET e2 = 100/o2
  221.            IF INT(c6+e2)< m6 THEN 2190
  222.            LET c6 = INT(13*m6/20)
  223.            LET e2 = 7*c6/13
  224.            LET u2 = 1
  225. 2170 'calculate simulated losses
  226.            PRINT 
  227. 2190 PRINT :PRINT :PRINT :PRINT 
  228.             PRINT " ","Confederacy","Union
  229.             LET c5 = (2*c1/5)*(1+1/(2*(ABS(y2-y)+1)))
  230.             LET c5 = INT(c5*(1+1/o)*(1.28+f1/(b(1)+1))+0.5)
  231.             LET e = 100/o
  232.             IF c5 + 100/o < m1*(1+(p1-t1)/(m3+1)) THEN 2270
  233.             LET c5 = INT (13*m1/20*(1+(p1-t1)/(m3+1)))
  234.             LET e = 7*c5/13
  235.             LET u = 1
  236. 2270 IF d = 1 THEN 2500
  237. 2280 PRINT "Casualties",c5,c6
  238.             PRINT "Desertions",INT(e),INT(e2)
  239.             PRINT 
  240.             IF b$ = "yes" THEN 2530
  241.             PRINT " Compared to the actual casualties at ";c$
  242.             PRINT " Confederate:"INT(100*(c5/c1)+0.5)"% of the original"
  243.             PRINT " Union:      "INT(100*(c6/c2)+0.5)"% of the original
  244.             PRINT 
  245.    ' Who won? 
  246.             IF u <> 1 THEN 2380
  247.             IF u2 = 1 THEN 2460
  248.             
  249. 2380 IF u = 1 THEN 2420
  250.              IF u2 = 1 THEN 2440
  251.              IF c5+e = c6 + e2 THEN 2460
  252.              IF c5+e < c6+e2 THEN 2440
  253. 2420 PRINT " The Union wins ";c$
  254.              GOTO 2600
  255. 2440 PRINT " The Confederacy wins ";c$
  256.              GOTO 2660
  257. 2460 PRINT " Battle outcome unresolved."
  258.              LET wo = wo + 1
  259.              IF a = 0 THEN 2790
  260.              GOTO 2680
  261. 2500 LET c6 = INT(17*c2*c1/(c5*20))
  262.              LET e2 = 5*o
  263.              GOTO 2280
  264. 2530 PRINT " Your casualties were "INT(100*(c5/c1)+0.5)% of
  265.              PRINT "the actual casualties at ";c$
  266.              PRINT 
  267.        'find who won...
  268.              IF u = 1 THEN 2590
  269.              IF c5 +e< 17*c2*c1/(c5*20)+5*o THEN 2630
  270. 2590 PRINT " You lose ";c$
  271. 2600 IF a =0 THEN 2790
  272.               LET l = l+1
  273.               GOTO 2680
  274.               PRINT " You win ";c$
  275.        'Cumulative battle factors which alter historical
  276.        'resources available. If a replay don't update.
  277. 2660 IF a = 0 THEN 2790
  278.                LET w = w+1
  279. 2680 LET t1 = t1 +c5 +e
  280.                LET t2 = t2 +c6 +e2
  281.                LET p1 = p1 + c1
  282.                LET p2 = p2 + c2
  283.                LET q1 = q1 + (f(1)+ h(1) + b(1))
  284.                LET q2 = q2 + (f(2)+ h(2) + b(2))
  285.       
  286.                LET r1 = r1 + m1*(100-i1)/20
  287.                LET r2 = r2 = m2*(100-i2)/20
  288.                LET m3 = m3 + m1
  289.                LET m4 = m4 + m2
  290.          GOSUB 3300
  291. 2790 u = 0: u2 = 0
  292.                PRINT "---------------"
  293.          GOTO 620
  294.         'finish off
  295. 2830 PRINT " The Confederacy has surrendered."
  296.                GOTO 2860
  297.                
  298. 2850 PRINT " The Union has surrendered."
  299.  2860 PRINT 
  300.                PRINT 
  301.                PRINT 
  302.                PRINT " The Confederacy has won "w" battles and lost "l
  303.                IF y = 5 THEN 2940
  304.                IF y2 = 5 THEN 2940
  305.                IF w<=l THEN 2940
  306.                IF y = 5 THEN 2940
  307.                PRINT " The Confederacy has won the war."
  308.             GOTO 2950
  309. 2940 PRINT " The Union has won the war."
  310. 2950 PRINT 
  311.                 IF r1 = 0 THEN 3100
  312.         PRINT " For the "w+l+wo" battles fought (excluding reruns)"
  313.              PRINT " "," "," ";
  314.              PRINT " Confederacy"," Union"
  315.              PRINT "Historical losses",INT (p1+0.5),INT (p2 + 0.5)
  316.              PRINT "Simulated losses",INT (t1 + 0.5),INT (t2 + 0.5)
  317.              PRINT 
  318.   PRINT "    % of original",INT (100*(t1/p1)+0.5),INT (100* (t2/p2)+0.5)
  319.               IF b$ = "yes" THEN 3100
  320.               PRINT 
  321.               PRINT " Union Intelligence suggests that the South used"
  322.            PRINT "Strategies 1, 2, 3, 4 in the following percentages."
  323.               PRINT  s(1);s(2);s(3);s(4)
  324.          '--------------------------------------------------------------
  325.           
  326. 3100 STOP
  327.                
  328. 3110 ' - Union strategy is Computer chosen
  329.            PRINT " Union Strategy is ";
  330.          IF a <> 0 THEN 3180
  331. 3140 INPUT y2
  332.          IF y2 <=0 THEN 3160
  333.          IF y2 < 5 THEN 3290
  334. 3160 PRINT " Enter 1, 2, 3, or 4 (usually previous Union strategy)"
  335.          GOTO 3140
  336. 3180 LET so = 0
  337.          LET r = 100*RND (0)
  338.          FOR i = 1 TO 4
  339.          LET so = so + s(i)
  340.      ' if actual strategy is in data statements
  341.      ' then r-100 is extra weight given to that strategy.
  342.          IF r<so THEN 3270
  343.          NEXT i
  344.       ' if actual strategy is in then here is y2 = hist strategy
  345.          
  346.  3270 LET y2 = i
  347.          PRINT y2
  348.          
  349. 3290 RETURN
  350.  
  351. 3300 ' learn present strategy, start forgetting old ones
  352.      ' present strategy of South gains 3*s, others lose s
  353.      ' probability points, unless a strategy falls below 5%.
  354.      
  355.          LET s = 3
  356.          LET so = 0
  357.         FOR i = 1 TO 4
  358.          IF s(i) <= 5 THEN 3390
  359.          LET s(i) = s(i) - s
  360.          LET so = so + s
  361.           
  362. 3390 NEXT i
  363.          LET s(y) = s(y) + so
  364.       RETURN
  365.    ' Historical data...can add more (strat.,etc) by inserting
  366.    ' Data statements after appro. info and adjusting read
  367.    
  368. DATA "Bull Run",18000,18500,1967,2708,1
  369. DATA "Shiloh",40000.,44894.,10699,13047,3
  370. DATA "Seven Days",95000.,115000.,20614,15849,3
  371. DATA "Second Bull Run",54000.,63000.,10000,14000,2
  372. DATA "Antietan",40000.,50000.,10000,12000,3
  373. DATA "Fredericksburg",75000.,120000.,5377,12653,1
  374. DATA "Murfreesboro",38000.,45000.,11000,12000,1
  375. DATA "Chancellorsville",32000.,90000.,13000,17197,2
  376. DATA "Vicksburg",50000.,70000.,12000,19000,1
  377. DATA "Gettysburg",72500.,85000.,20000,23000,3
  378. DATA "Chickamauga",66000.,60000.,18000,16000,2
  379. DATA "Chattanooga",37000.,60000.,36700,5800,2
  380. DATA "Spotsylvania",62000.,110000.,17723,18000,2
  381. DATA "Atlanta",65000.,100000.,8500,3700,1
  382.  
  383. 3580 PRINT " July 21, 1861. Gen. Beauregard, commanding the South, met
  384. PRINT "Union forces with Gen. McDowell in a premature battle at"
  385. PRINT "Bull Run. Gen Jackson helped push back the Union attack."
  386.       GOTO 1150
  387.  3620 PRINT " Apreil 6-7, 1862. The Confederate surprise attack at"
  388.  PRINT "Shiloh failed due to poor organization."
  389.        GOTO 1150
  390. 3650 PRINT " June 25 - July 1, 1862. General Lee (CSA) upheld the"
  391. PRINT "offensive throughout the battle and forced Gen. Mc Lellan"
  392. PRINT "and the Union forces away from Richmond."
  393.       GOTO 1150
  394. 3690 PRINT " Aug. 29-30, 1862. The combined Confederate forces under"
  395. PRINT "Lee and Jackson drove the Union forces back into Washington."
  396.       GOTO 1150
  397. 3720 PRINT " Sept 17, 1862. The South failed to incorporate Maryland"
  398. PRINT "into thre Confederacy."
  399.       GOTO 1150
  400. 3750 PRINT " Dec. 13, 1862. The Confederacy under Lee sucessfully"
  401. PRINT "repulsed an attack by the Union under Gen. Burnside."
  402.       GOTO 1150
  403. 3780 PRINT " Dec. 31, 1862. The South under Gen. Bragg won a close battle."
  404.       GOTO 1150
  405. 3800 PRINT " May 1-6, 1863. The South had a costly victory and lost
  406. PRINT "one of their outstanding Generals, `Stonewall' Jackson."
  407.       GOTO 1150
  408. 3830 PRINT " July 4, 1863. Vicksburg was a costly defeat for the South"
  409. PRINT "because it gave the Union access to the Mississippi."
  410.       GOTO 1150
  411. 3860 PRINT " July 1-3, 1863. A Southern mistake by Gen. Lee at Gettysburg"
  412. PRINT "cost them one of the most crucial battles of the war."
  413.       GOTO 1150
  414. 3890 PRINT " Sept. 15, 1863. Confusion in a forest near Chickamauga led"
  415. PRINT "to a costly Southern victory."
  416.       GOTO 1150
  417. 3920 PRINT " Nov. 25, 1863. After the South had sieged Gen. Rosencrans'"
  418. PRINT "army for three months, Gen. Grant broke the siege."
  419.       GOTO 1150
  420. 3950 PRINT " May 5, 1864. Grant's plan to keep Lee isolated began to"
  421. PRINT "fail here, and continued at Cold Harbor and Petersburg."
  422.       GOTO 1150
  423. 3980 PRINT " August, 1864. Sherman and three veteran armies converged"
  424. PRINT "on Atlanta and dealt the death blow to the Confederacy."
  425.       GOTO 1150
  426.  
  427. SETSCREEN:      
  428.  
  429.      rgb 0,9,9,9 'paper
  430.      rgb 1,0,5,10'pen
  431.      rgb 2,13,0,0'field
  432.      rgb 3,15,15,0 'highlight
  433.      
  434.      SUB rgb(n%,r%,g%,b%) STATIC
  435.       PALETTE n%,r%/16,g%/16,b%/16
  436.      END SUB
  437.   RETURN
  438.       
  439.       END
  440.                                                                   
  441.                           
  442.          
  443.     
  444.               
  445.               
  446.     
  447.     
  448.     
  449.     
  450.     
  451.   
  452.  
  453.  
  454.  
  455.